package fr.afcepf.atod19.dreamproject.dao.implementation;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.transaction.annotation.Transactional;

import fr.afcepf.atod19.dreamproject.dao.interfaces.TestIDaoClient;
import fr.afcepf.atod19.dreamproject.entity.Client;

@Transactional
public class TestDaoClient implements TestIDaoClient {
	
	@PersistenceContext
	private EntityManager em;
	
	public TestDaoClient() {
		System.out.println("dans le constructeur du daoClient");
	}

	public int createClient(Client c){
		System.out.println("<DaoClient : createClient");
		 em.persist(c);
		 System.out.println(">DaoClient : createClient");
		 int b = c.getIdClient();
		 em.close();
		 return b;
	}

	public EntityManager getEm() {
		return em;
	}

	public void setEm(EntityManager em) {
		this.em = em;
	}

}
